<%@  page  contentType=" application/vnd.ms-excel;  charset=utf-8"%>
<% response.setHeader("Content-disposition","attachment; filename=test.xls");
%>
  <% response.setContentType("application/vnd.ms-excel;charset=GBK"); %>   

  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<style type="text/css">
td{
text-align:center
}
</style>
<script type="text/javascript"> 

function saveCode(obj) { 
          var winname = window.open('', '_blank', 'top=10000'); 
          var strHTML = document.all.tableExcel.innerHTML; 
          winname.document.open('text/html', 'replace'); 
          winname.document.writeln(strHTML); 
          winname.document.execCommand('saveas','','excel.xls'); 
          winname.close(); 
} 

</script> 

</head> 

<body> 
<div id="tableExcel" >  
<table class="table" width="100%" layoutH="138">
		<thead>
		<tr>
		<th width="2%"></th>
		<th width="5%">货品数量</th>
		<th width="7%">调拨时间</th>
		<th width="5%">操作员</th>
		<th width="5%">状态</th>
        <th width="8%">目标部门</th>
        <th width="10%">流水号</th>
        <th width="10%">原部门</th>
        <th width="10%">商品类型</th>
        </tr>
        </thead>
		<tbody>
		
			<c:forEach items="${requestScope.lsit}" var="s" varStatus="ff">
			<c:choose><c:when test="${s.status=='0'}">
			<tr>
             </c:when><c:when test="${s.status=='1'}">
             <tr style="color: green;">
			 </c:when><c:otherwise>
			 <tr style="color: red;">
			 </c:otherwise></c:choose>		
			 <td align="center">${ff.index+1 }</td>
            
			 <td >${s.allocatenum }</td>
			 <td >${s.create_time }</td>
			 <td >${s.operator }</td>
             <c:choose><c:when test="${s.status=='0'}"><td  id="status">在途</td></c:when>
             <c:when test="${s.status=='1'}"><td id="status">确认</td></c:when>
             <c:otherwise><td id="status">回退</td></c:otherwise></c:choose>
             <td >${s.to_dept}</td>
			 <td >${s.code }</td>
			 <td >${s.from_dept }</td>
			 <td >${s.goodtype }</td>
			 </tr>
	</c:forEach>
		</tbody>
	</table>
	</div>
<input type="button" value="另存为 Excel" onclick="saveCode(tableExcel)"> 
</body> 
</html>